

import 'package:flutter/material.dart';
import 'package:moonplay/common/app_common.dart';


class LoginPage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        children: <Widget>[
          RaisedButton(
            onPressed: (){
              login();
            },
            child: Text('登录'),
          ),
          RaisedButton(
            onPressed: (){
              init();
            },
            child: Text('请求首页'),
          ),
        ],
      ),
    );
  }

  login() async {
    Map<String, dynamic> postData = {
      "method": "user.login",
      "request_token":"",
      "mobile":"17691187009",
      "password":"123456",
      "sms_code":"123456",
      "token":"",
      "longitude":"",
      "latitude":""
    };

    await HttpUtil().request("", data: postData, need_login: false).then((res) {
      logger.d(res);
    });
  }

  init() async {
    Map<String, dynamic> postData = {
      "method": "user.login",
      "request_token":"",
      "mobile":"17691187009",
      "password":"123456",
      "sms_code":"123456",
      "token":"",
      "longitude":"",
      "latitude":""
    };
    await HttpUtil().request("", data: postData, need_login: false).then((res) {
      logger.d(res);
    });
  }
}